const App = getApp();
import { goLogin } from '../../../utils/util.js'
import { loginOut } from '../../../api/getData.js';

Component({
  properties: {
    showBack: {
      type: String,
      value: false
    }, 
  },

  data: {
    showUp: false,
    username: null,
    groups: ['异常信息', '退出登录']
  },
  
  attached(){
    this.setData({
      username: wx.getStorageSync('username')
    })
  },

  methods: {
    actionSheetTap: function () {
      wx.showActionSheet({
        itemList: this.data.groups,
        success: function (res) {
          if(res.tapIndex === 1){
            loginOut()
            .then(res => {
              if (res.resCode === 'SUCCESS'){
                
              }
            })
            goLogin();
            App.globalData.result = null;
            wx.clearStorage();
            
          }
          if (res.tapIndex === 0) {
            wx.navigateTo({
              url: "../../pages/errorInformation/errorInformation"
            })
          }
        }
      })
    },
    // 回到上一页
    goBack(){
      wx.setStorageSync('canRequest', true)
      wx.reLaunch({
        url: "../../pages/totalMsg/totalMsg"
      })
    }
  }
})